<template>
	<view class="news">
		<new-item :data="newsList" @clickItem="goDetail">></new-item>
	</view>
</template>

<script>
	import newItem from '@/components/news-item/news-item.vue'

	export default {
		components: {
			"new-item": newItem
		},
		data() {
			return {
				newsList: []
			}
		},
		methods: {
			async getNewsList() {
				const res = await this.$myRuquest({
					url: '/api/getnewslist'
				})
				this.newsList = res.data.message
			},
			goDetail (id) {
				console.log(id)
				uni.navigateTo({
					url: '/pages/news-detail/news-detail?id='+id
				})
			}
		},
		onLoad() {
			this.getNewsList()
		},


	}
</script>

<style scoped="scss">

</style>
